package com.wrk._2_数组._01_课件;

import java.util.Arrays;

public class _006_冒泡排序 {
    public static void main(String[] args) {
        int[] array = {1,10,6,34,887,12,11};
        //外层循环轮询比对次数
        for (int i = 0; i < array.length-1; i++) {
            //内层循环，进行 数据比对
            for (int j = 0; j < array.length-1-i; j++) {
                //判断第一个数是否和第二个数大，进行数字交换
                if (array[j+1] < array[j] ){
                    int sum = array[j+1];
                    array[j+1] = array[j];
                    array[j] = sum;
                }
            }
        }
        System.out.println(Arrays.toString(array));
    }
}
